home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
I-Z
/
ResExpress 1.0.sea
/
ResExpress 1.0
/
ResX DevKit
/
Think Pascal
/
RXXT Shell w_Globals.p
< prev
next >
Wrap
Text File
|
1990-01-04
|
6KB
|
145 lines
unit RXXTShell;
{RXXT Shell for ResX Externals}
{To compile in Think Pascal:}
{ 1) Set Project Type to 'Code Resource' }
{ 2) Set the File TYPE to 'RXXT' and File Creator to 'ResX'}
{ 3) Set the Resource TYPE to 'RXXT' }
{ 4) Set the Resource NAME to the name of the external as it should appear in the}
{ Externals menu. A hex editor external could be named 'Hex Editor'.}
{ 5) Add this file, DRVRRuntime.lib, and Interface.lib to the project }
{ 6) Compile the code resource. }
{ 7) Install it in ResX via the 'Externals->Install' menu. Or double-click on the external file in Finder. }
{PRE-CONDITIONS}
{ 1) The handle to the current selected resource is passed directly into main.}
{ 2) The resource of that handle is NOT loaded. It must be loaded if used.}
{ 3) The handle to the resource is NOT detached!}
{ 4) The Global Data address is stored in the reference constant of the daWindow. See example below on}
{ how to access the globals.}
{ 5) It is mandatory to get the state of the handle (HGetState). Restore the state when finished.}
{POST-CONDITIONS}
{ 1) Do NOT release the resource or dispose the handle to the resource. ResX will do it when}
{ necessary. ResX will check to see if the resource has been loaded by another environment.}
{ 2) Restore the state of the handle when finished (HSetState).}
{EXCEPTIONS}
{ 1) If writing an external that does not deal with the current selected resource (such as a}
{ 'Copy Data Fork' external or maybe one that acts on all resources), it is not necessary to}
{ load the resource (ResHandle) and it is not necessary to save/restore the handle state }
{ (HGetState/HSetState not required).}
interface
procedure main (ResHandle: Handle); {Handle of the current selected resource}
implementation
procedure main;
type
SettingsHandle = ^SettingsPtr; {Contains Configuration setup, last and second}
SettingsPtr = ^SettingsRec; {to last files opened, and last move info}
SettingsRec = record
unused1: Boolean;
openStartup: Boolean; {Enable/Disable Open on Startup options}
sortTList, sortRList: Boolean; {Sort Type/Resource list}
lastOneRefNum, lastTwoRefNum: integer; {Last/Second to last volume reference number}
lastOneName, lastTwoName: Str255; {Last/Second to last file name}
lastMoveType: ResType; {TYPE of the last resource copied}
lastMoveID: integer; {Resource ID of the last resource copied}
lastMoveSource, lastMoveDest: Str255; {Source and Dest Files of the last resource copied}
onStartup: integer; {Open on startup option: 1-Last File, 2-Last Two Files, 3-Open File Dialog}
unused2: integer;
dClick: integer; {Current selected item of DoubleClick popup menu}
helpFName: Str255; {Location of master Help file}
end;
GlobalsHndl = ^GlobalsPtr; {ResX Global Data - Most data can be programmably}
GlobalsPtr = ^GlobalsRec; {altered. Alter with care! * denotes DO NOT alter}
GlobalsRec = record
theDevCtlEnt: DCtlPtr; {*Device Control Entry for DA*}
rsrcBase: Integer; {*Resource Base*}
daMenu: MenuHandle; {Main DA Menu}
daFileID: Longint; {*File ID of DA*}
LeftFName, RightFName: Str255; {Path and Name of Left & Right files currently opened}
LeftVNum, RightVNum: integer; {vRefNum of Left & Right files}
LWasOpened, RWasOpened: Boolean; {Left/Right file was opened priorly and shouldn't be closed}
LcurType, RcurType: ResType; {Current type displayed above resource lists}
LTcurCell, RTcurCell: Cell; {Current selected cell in Left/Right TYPE list}
LRcurCell, RRcurCell: Cell; {Current selected cell in Left/Right RESOURCE list}
LfileID, RfileID: integer; {Left/Right File ID}
prefsID: integer; {File ID of ResX Prefs in the System Folder}
CompactLeft, CompactRight: Boolean; {Left/Right resource map will be compacted when closed if TRUE}
favMenu, extMenu, openMenu: MenuHandle; {*Favorite File/Externals/Open File MenuHandles}
Lopen, Ropen: Boolean; {True if Left/Right file is open and displayed in ResX}
MFActive: Boolean; {*True if MultiFinder is running*}
Settings: SettingsHandle; {Handle to Settings in Configuration setup}
LTypeList: ListHandle; {Handle to Left Type list}
RTypeList: ListHandle; {Handle to Right Type list}
LResList: ListHandle; {Handle to Left Resource list}
RResList: ListHandle; {Handle to Right Resource list}
Info: ControlHandle; {Get Info Button Control Handle}
View: ControlHandle; {View Button Control Handle}
OpenLeft: ControlHandle; {Open Left Button Control Handle}
OpenRight: ControlHandle; {Open Right Button Control Handle}
Remove: ControlHandle; {Remove Button Control Handle}
Copy: ControlHandle; {Copy Button Control Handle}
end; {DO NOT alter globals denoted with *. They can}
{be accessed for reference only.}
var
fileID, rsrID: integer;
rsrType: ResType;
rsrName, fName: Str255;
HState: SignedByte;
MF: Boolean;
Globals: GlobalsPtr;
begin
Globals := GlobalsPtr(WindowPeek(FrontWindow)^.refCon); {Required to access the Global Data}
{Sample of accessing the global data: }
fileID := Globals^.LFileID; {Get the file id left file}
fName := Globals^.LeftFName; {Get the file name of the left file}
MF := Globals^.MFActive; {Is MultiFinder running?}
HState := HGetState(ResHandle); {This is mandatory!}
LoadResource(ResHandle); {This is necessary if you plan to use it. }
{ResX doesn't load it.}
{.......}
{main code here}
{.......}
HSetState(ResHandle, HState); {This is mandatory!}
{Do NOT release the resource or dispose the handle, ResX will do it if necessary. }
{This is critical in case the resource is being used by a currently running application. }
end;
end.